package locutor.draft.locutor

import java.io.File

import scaup.Views._



object CIA extends Application {
  
  // Given a file <code> f </code> in two different versions …
  
  val f1: File = "src/draft/locutor/draft/locutor/bookV1.xml".toFile
  val f2: File = "src/draft/locutor/draft/locutor/bookV2.xml".toFile
  
  // … and a dependency graph Ḡ of
  
//  val ℳ = modelOf(f1)
  
}

//import java.io.File
//
//import scala.xml.{Document, Node}
//
//import scaup.Views._
//import scaup.E
//
//import scalaxx.diff.Command
//import scalaxx.diff.Differ.{xmldiff => diff}
//
//private [locutor] object Util {
//  
//  def infoset(f: File): (Document, ℳ) = (astOf(f), modelOf(f))
//  def astOf(f: File) = xml.parsing.ConstructingParser.fromFile(f, true).document  
//  def modelOf(f: File): ℳ = ℳ(dgOf(f), ℰ(), ℛ())
//  
//  /* A document model */
//  case class ℳ(val g: Ḡ, val e: ℰ, val r: ℛ) {
//    def ↩ (commands: List[Command]) = error("not yet implemented")
//  }
//  
//  /* A dependency graph */
//  case class Ḡ()
//  
//  /* A set of inference rules */
//  case class ℛ()
//  
//  /* A equivalence model */
//  case class ℰ() extends E[Node]    
//  
//  def dgOf(f: File): Ḡ = error("") //DG(f/".dep")  
//  
//  def ℰ (m: ℳ) = m.e
//  def Ḡ (m: ℳ) = new {
//    def ↩ (commands: List[Command]) = new {
//      def having(m: ℳ) = m ↩ commands
//    }
//  }
//  def ℛ (m: ℳ) = m
//}
//import Util._
//
//object MoC {  
//  /** MoC[CIA] workflow */
//  def main(args: Array[String]): Unit = {
//    
//    // Given a file in two different versions.
//    
//    val f1: File = "src/draft/locutor/draft/locutor/bookV1.xml".toFile
//    val f2: File = "src/draft/locutor/draft/locutor/bookV2.xml".toFile
//    
//    // In the first phase we retrieve the information set of f₁
//    // 
//    // An information set is a pair constituted of an AST of f₁ and a document model of f₁.
//    //  
//    // In contrast to common folklore, once built, /no/ additional information is added to the AST by
//    // subsequent processing, e.g., semantic analysis.  Sensitive data -- in sense of change management --
//    // potentially retrieved by semantic analysis is (already) represented within the corresponding
//    // document model.
//    //
//    // A document model ℳ = <Ḡ, ℰ, ℛ> is a triple constituted of
//    //  o a dependency graph Ḡ = <I, D>. Ḡ is a directed, classified, labeled multi-graph,
//    //    where I is the set of INFOMs and D ⊆ I X I is the set of dependencies both classified.
//    //  o a set of equiv-relations ℰ on Ḡ(I)      
//    //  o a rule system ℛ = <ℙ, ℂ>, where ℙ denotes a set of propagation rules on Ḡ
//    //    and ℂ a set of consistency rules for Ḡ.
//    //
//    // A dependency graph describes the dependencies of f₁, i.e. dependencies between INFOMs of f₁ as well as 
//    // between INFOMs within other files.
//    
//    val (d1: Document, m: ℳ) = infoset(f1)  
//    
//    // In the second phase we compute the model-based changeset δ of d₁ to d₂ with resepect to ℰ,
//    // such that @(δ, d₁) = d₂ holds.
//    //
//    // Note: Think of ``@'' as apply or patch.    
//    //
//    // Note: The differencing algorithm uses ℰ only!
//    //  
//    // Note: At the moment a document model only consists of ℰ!  Current work on ↩, in particular,
//    //       will justify the above defined triple.    
//
//    val δ : List[Command] = diff(ℰ(m), d1, astOf(f2))
//    
//    // In the third phase we compute the extended changeset Δ of d1
//    // by rippling (↩) δ into Ḡ(ℳ) in consideration of ℛ(ℳ) (short ℳ ↩ δ),
//    // such that δ ⊴ Δ, @(Δ|δ, d₁) = d₂ and @(Δ\δ, d₂) = d₃.    
//    
//    val Δ : List[Command] = Ḡ(m) ↩ δ having ℛ(m)
//    assert(Δ == m ↩ δ)
//    
//    // The fourth and final phase is a preview 
//    
//    Δ partition (c => δ exists (_ == c)) match { case (localEffects, rippleEffects) =>
//      assert(localEffects == δ)
//      println("Changeset:\n"+localEffects)
//      println("----")
//      println("Ripple Effects:\n"+rippleEffects)
//    }
//  }
//}
